package panel.media
{
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class MediaPlayPauseBtn extends Sprite
	{
		private var _loader:ResourceLoader;
		private var _playBtn:Bitmap;
		private var _pauseBtn:Bitmap;
		private var _onPlayPauseFunc:Function;
		public function MediaPlayPauseBtn(loader:ResourceLoader)
		{
			_loader = loader;
			super();
			layoutUI();
		}
		
		private function layoutUI():void
		{
			_playBtn = _loader.uiManager.generateBmp(_loader.uiManager.playPng);
			_pauseBtn = _loader.uiManager.generateBmp(_loader.uiManager.stopPng);
			this.addChild(_playBtn);
			this.addChild(_pauseBtn);
			_playBtn.visible = false;
			_pauseBtn.visible = true;
			resize(); 
		}
		
		private function resize():void
		{
			_playBtn.x = (this.width - _playBtn.width)/2;
			_playBtn.y = (this.height - _playBtn.height)/2;
			_pauseBtn.x = (this.width - _pauseBtn.width)/2;
			_pauseBtn.y = (this.height - _pauseBtn.height)/2;
		}
		
		public function changeState():Boolean
		{
			if(_playBtn.visible)
			{
				_playBtn.visible = false;
				_pauseBtn.visible = true;
			}else
			{
				_playBtn.visible = true;
				_pauseBtn.visible = false;
			}
			return _playBtn.visible;
		}
		
	}
}